import React, { Component } from 'react';

import './index.less';





class Header extends Component {
    constructor(props) {
        super(props);
        this.buttonClickHandle = this.buttonClickHandle.bind(this);
    }
    buttonClickHandle(props, btnCode){
        switch (btnCode) {
            case 'add':  // 新增
                this.props.addOperation();
                break;
            case 'edit':  // 编辑
                this.props.editOPeration();
                break;
            case 'delete':  // 删除
                this.props.deleteOperation();
                break;
            case 'query':  // 查询
                this.props.searchOperation();
                break;
            case 'save':  // 保存
                this.props.saveOperation();
                break;
            case 'cancel':  // 取消
                this.props.cancelOperation();
                break;
            case 'refresh':  // 刷新
                this.props.refreshOperation();
                break;
            case 'reset':  // 管理范围重置
                this.props.resetOperation();
                break;  
            default:
                break;
        }
        
    }
    render() {
        const {
            button,
        } = this.props;
        return (
            <div className="header nc-bill-header-area">
                <div className="btn-group">
                    <div className="definition-icons">
                        {button.createButtonApp({
                            area: 'head',
                            onButtonClick: this.buttonClickHandle
                        })}
                    </div>
                </div>
            </div>
        );
    }
}

export default Header;
